<extend name="Base/layout" />
<block name="content">
<div class="" style="margin-bottom: 10px;">
<button class="layui-btn layui-btn-normal" id="add-user"><i class="layui-icon" style="">&#xe654;</i>添加管理员或普通管理员</button>
<button class="layui-btn layui-btn-danger" onclick="Admin.delete_users()"><i class="layui-icon" style="">&#xe640;</i>批量删除</button>
</div>
<table class="layui-table layui-form" id="user">
    <colgroup>
    <col width="30">
    </colgroup>
  	<thead>
	    <tr>
            <th><input type="checkbox" lay-skin="primary" lay-filter="user" name="select_all"></th>
	      	<th>ID</th>
            <th>管理员名</th>
            <th>上次登录IP</th>
	      	<th>创建时间</th>
            <th>上次登录时间</th>
            <th>管理员</th>
            <th>操作</th>
	    </tr> 
  	</thead>
  	<tbody>
        <foreach name="user"  item="user">
    	<tr data-id="{$user.id}">
            <td><input type="checkbox" lay-skin="primary" name="select" value="{$user.id}"></td>
	      	<td>{$user.id}</td>
            <td><a>{$user.adminuser}</a><if condition="$user['adminuser'] == $username"><i class="layui-icon" title="当前管理员" style="margin-left: 5px;cursor: pointer;">&#xe600;</i></if></td>
	      	<td>{$user['lastip'] ? $user['lastip'] : '无'}</td>
            <td>{$user.createtime|date='Y-m-d H:i:s',###}</td>
            <td><php>$lasttime = $user['lasttime'] == 0 ? '无' : date('Y-m-d H:i:s', $user['lasttime']);</php>{$lasttime}</td>
            <td data-id="{$user.id}"><input type="checkbox" name="role" lay-filter="role" lay-skin="switch" lay-text="是|否" <if condition="$user['role_id']">checked</if>></td>
            <td>
                <a class="layui-btn layui-btn-normal layui-btn-sm" onclick="Admin.edit_user('{$user.id}')"><i class="layui-icon" style="">&#xe642;</i></a>
                <a class="layui-btn layui-btn-danger layui-btn-sm delete_art" onclick="Admin.delete_user('{$user.id}')"><i class="layui-icon" style="">&#xe640;</i></a>
            </td>
    	</tr>
        </foreach>
  	</tbody>
</table>
<script type="text/template" id="edit_user_container">
    <div class="template-box">
        <form class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <label class="layui-form-label">名称</label>
                <div class="layui-input-block">
                    <input type="adminuser" name="adminuser" lay-verify="adminuser" autocomplete="off" class="layui-input" disabled="">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" lay-verify="password" placeholder="请输入新密码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" pane>
                <label class="layui-form-label">管理员</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="role" lay-skin="switch" lay-text="是|否">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="eidt_user">确定</button>
                    <button type="button" class="layui-btn layui-btn-primary btn-cancel">取消</button>
                </div>
            </div>
        </form>
    </div>
</script>

<script type="text/template" id="add_user_container">
    <div class="template-box">
        <form class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="adminuser" lay-verify="username" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" lay-verify="password" placeholder="请输入标题" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" pane>
                <label class="layui-form-label">管理员</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="role" lay-skin="switch" lay-text="是|否">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">验证码</label>
                <div class="layui-input-inline">
                    <input type="text" name="code" lay-verify="code" placeholder="请输入验证码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <img id="verify" alt="点击更换" title="点击更换" src="{:U('Admin/Account/verify',array())}" class="verify" onclick="this.src='{:U('Admin/Account/verify',rand())}'+'?'+Math.random()">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="add-user">确定</button>
                    <button type="button" class="layui-btn layui-btn-primary btn-cancel">取消</button>
                </div>
            </div>
        </form>
    </div>
</script>
</block>
<block name="urls">
    user:"{:U('Admin/admin/index')}",
    deleteUser:"{:U('Admin/admin/deleteUser')}",
    roleUser:"{:U('Admin/admin/roleUser')}",
    addUser:"{:U('admin/Account/reg')}",
    editUser:"{:U('admin/admin/editUser')}"
</block>
<block name="javascript">
    <script type="text/javascript" src="__JS__/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="__JS__/admin.js"></script>
    <script type="text/javascript">
    $(function(){
        Admin.initialize();
    });
    </script>
</block>